In [2]:
import pandas as pd
In [3]:
import json
from pandas.io.json import json_normalize
In [3]:
# define json string
data = [{'state': 'Florida',
'shortname': 'FL',
'info': {'governor': 'Rick Scott'},
'counties': [{'name': 'Dade', 'population': 12345},
{'name': 'Broward', 'population': 40000},
{'name': 'Palm Beach', 'population': 60000}]},
{'state': 'Ohio',
'shortname': 'OH',
'info': {'governor': 'John Kasich'},
'counties': [{'name': 'Summit', 'population': 1234},
{'name': 'Cuyahoga', 'population': 1337}]}]
In [4]:
# use normalization to create tables from nested element
json_normalize(data, 'counties')
Out[4]:
name
population
0
Dade
12345
1
Broward
40000
2
Palm Beach
60000
3
Summit
1234
4
Cuyahoga
1337
In [5]:
# further populate tables created from nested element
json_normalize(data, 'counties', ['state', 'shortname', ['info', 'governor']])
Out[5]:
name
population
shortname
state
info.governor
0
Dade
12345
FL
Florida
Rick Scott
1
Broward
40000
FL
Florida
Rick Scott
2
Palm Beach
60000
FL
Florida
Rick Scott
3
Summit
1234
OH
Ohio
John Kasich
4
Cuyahoga
1337
OH
Ohio
John Kasich
In [6]:
# load json as string
json.load((open('data/world_bank_projects_less.json')))
Out[6]:
[{'_id': {'$oid': '52b213b38594d8a2be17c780'},
'approvalfy': 1999,
'board_approval_month': 'November',
'boardapprovaldate': '2013-11-12T00:00:00Z',
'borrower': 'FEDERAL DEMOCRATIC REPUBLIC OF ETHIOPIA',
'closingdate': '2018-07-07T00:00:00Z',
'country_namecode': 'Federal Democratic Republic of Ethiopia!$!ET',
'countrycode': 'ET',
'countryname': 'Federal Democratic Republic of Ethiopia',
'countryshortname': 'Ethiopia',
'docty': 'Project Information Document,Indigenous Peoples Plan,Project Information Document',
'envassesmentcategorycode': 'C',
'grantamt': 0,
'ibrdcommamt': 0,
'id': 'P129828',
'idacommamt': 130000000,
'impagency': 'MINISTRY OF EDUCATION',
'lendinginstr': 'Investment Project Financing',
'lendinginstrtype': 'IN',
'lendprojectcost': 550000000,
'majorsector_percent': [{'Name': 'Education', 'Percent': 46},
{'Name': 'Education', 'Percent': 26},
{'Name': 'Public Administration, Law, and Justice', 'Percent': 16},
{'Name': 'Education', 'Percent': 12}],
'mjsector_namecode': [{'code': 'EX', 'name': 'Education'},
{'code': 'EX', 'name': 'Education'},
{'code': 'BX', 'name': 'Public Administration, Law, and Justice'},
{'code': 'EX', 'name': 'Education'}],
'mjtheme': ['Human development'],
'mjtheme_namecode': [{'code': '8', 'name': 'Human development'},
{'code': '11', 'name': ''}],
'mjthemecode': '8,11',
'prodline': 'PE',
'prodlinetext': 'IBRD/IDA',
'productlinetype': 'L',
'project_abstract': {'cdata': 'The development objective of the Second Phase of General Education Quality Improvement Project for Ethiopia is to improve learning conditions in primary and secondary schools and strengthen institutions at different levels of educational administration. The project has six components. The first component is curriculum, textbooks, assessment, examinations, and inspection. This component will support improvement of learning conditions in grades KG-12 by providing increased access to teaching and learning materials and through improvements to the curriculum by assessing the strengths and weaknesses of the current curriculum. This component has following four sub-components: (i) curriculum reform and implementation; (ii) teaching and learning materials; (iii) assessment and examinations; and (iv) inspection. The second component is teacher development program (TDP). This component will support improvements in learning conditions in both primary and secondary schools by advancing the quality of teaching in general education through: (a) enhancing the training of pre-service teachers in teacher education institutions; and (b) improving the quality of in-service teacher training. This component has following three sub-components: (i) pre-service teacher training; (ii) in-service teacher training; and (iii) licensing and relicensing of teachers and school leaders. The third component is school improvement plan. This component will support the strengthening of school planning in order to improve learning outcomes, and to partly fund the school improvement plans through school grants. It has following two sub-components: (i) school improvement plan; and (ii) school grants. The fourth component is management and capacity building, including education management information systems (EMIS). This component will support management and capacity building aspect of the project. This component has following three sub-components: (i) capacity building for education planning and management; (ii) capacity building for school planning and management; and (iii) EMIS. The fifth component is improving the quality of learning and teaching in secondary schools and universities through the use of information and communications technology (ICT). It has following five sub-components: (i) national policy and institution for ICT in general education; (ii) national ICT infrastructure improvement plan for general education; (iii) develop an integrated monitoring, evaluation, and learning system specifically for the ICT component; (iv) teacher professional development in the use of ICT; and (v) provision of limited number of e-Braille display readers with the possibility to scale up to all secondary education schools based on the successful implementation and usage of the readers. The sixth component is program coordination, monitoring and evaluation, and communication. It will support institutional strengthening by developing capacities in all aspects of program coordination, monitoring and evaluation; a new sub-component on communications will support information sharing for better management and accountability. It has following three sub-components: (i) program coordination; (ii) monitoring and evaluation (M and E); and (iii) communication.'},
'project_name': 'Ethiopia General Education Quality Improvement Project II',
'projectdocs': [{'DocDate': '28-AUG-2013',
'DocType': 'PID',
'DocTypeDesc': 'Project Information Document (PID), Vol.',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=090224b081e545fb_1_0',
'EntityID': '090224b081e545fb_1_0'},
{'DocDate': '01-JUL-2013',
'DocType': 'IP',
'DocTypeDesc': 'Indigenous Peoples Plan (IP), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000442464_20130920111729',
'EntityID': '000442464_20130920111729'},
{'DocDate': '22-NOV-2012',
'DocType': 'PID',
'DocTypeDesc': 'Project Information Document (PID), Vol.',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=090224b0817b19e2_1_0',
'EntityID': '090224b0817b19e2_1_0'}],
'projectfinancialtype': 'IDA',
'projectstatusdisplay': 'Active',
'regionname': 'Africa',
'sector': [{'Name': 'Primary education'},
{'Name': 'Secondary education'},
{'Name': 'Public administration- Other social services'},
{'Name': 'Tertiary education'}],
'sector1': {'Name': 'Primary education', 'Percent': 46},
'sector2': {'Name': 'Secondary education', 'Percent': 26},
'sector3': {'Name': 'Public administration- Other social services',
'Percent': 16},
'sector4': {'Name': 'Tertiary education', 'Percent': 12},
'sector_namecode': [{'code': 'EP', 'name': 'Primary education'},
{'code': 'ES', 'name': 'Secondary education'},
{'code': 'BS', 'name': 'Public administration- Other social services'},
{'code': 'ET', 'name': 'Tertiary education'}],
'sectorcode': 'ET,BS,ES,EP',
'source': 'IBRD',
'status': 'Active',
'supplementprojectflg': 'N',
'theme1': {'Name': 'Education for all', 'Percent': 100},
'theme_namecode': [{'code': '65', 'name': 'Education for all'}],
'themecode': '65',
'totalamt': 130000000,
'totalcommamt': 130000000,
'url': 'http://www.worldbank.org/projects/P129828/ethiopia-general-education-quality-improvement-project-ii?lang=en'},
{'_id': {'$oid': '52b213b38594d8a2be17c781'},
'approvalfy': 2015,
'board_approval_month': 'November',
'boardapprovaldate': '2013-11-04T00:00:00Z',
'borrower': 'GOVERNMENT OF TUNISIA',
'country_namecode': 'Republic of Tunisia!$!TN',
'countrycode': 'TN',
'countryname': 'Republic of Tunisia',
'countryshortname': 'Tunisia',
'docty': 'Project Information Document,Integrated Safeguards Data Sheet,Integrated Safeguards Data Sheet,Project Information Document,Integrated Safeguards Data Sheet,Project Information Document',
'envassesmentcategorycode': 'C',
'grantamt': 4700000,
'ibrdcommamt': 0,
'id': 'P144674',
'idacommamt': 0,
'impagency': 'MINISTRY OF FINANCE',
'lendinginstr': 'Specific Investment Loan',
'lendinginstrtype': 'IN',
'lendprojectcost': 5700000,
'majorsector_percent': [{'Name': 'Public Administration, Law, and Justice',
'Percent': 70},
{'Name': 'Public Administration, Law, and Justice', 'Percent': 30}],
'mjsector_namecode': [{'code': 'BX',
'name': 'Public Administration, Law, and Justice'},
{'code': 'BX', 'name': 'Public Administration, Law, and Justice'}],
'mjtheme': ['Economic management', 'Social protection and risk management'],
'mjtheme_namecode': [{'code': '1', 'name': 'Economic management'},
{'code': '6', 'name': 'Social protection and risk management'}],
'mjthemecode': '1,6',
'prodline': 'RE',
'prodlinetext': 'Recipient Executed Activities',
'productlinetype': 'L',
'project_name': 'TN: DTF Social Protection Reforms Support',
'projectdocs': [{'DocDate': '29-MAR-2013',
'DocType': 'PID',
'DocTypeDesc': 'Project Information Document (PID), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000333037_20131024115616',
'EntityID': '000333037_20131024115616'},
{'DocDate': '29-MAR-2013',
'DocType': 'ISDS',
'DocTypeDesc': 'Integrated Safeguards Data Sheet (ISDS), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000356161_20131024151611',
'EntityID': '000356161_20131024151611'},
{'DocDate': '29-MAR-2013',
'DocType': 'ISDS',
'DocTypeDesc': 'Integrated Safeguards Data Sheet (ISDS), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000442464_20131031112136',
'EntityID': '000442464_20131031112136'},
{'DocDate': '29-MAR-2013',
'DocType': 'PID',
'DocTypeDesc': 'Project Information Document (PID), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000333037_20131031105716',
'EntityID': '000333037_20131031105716'},
{'DocDate': '16-JAN-2013',
'DocType': 'ISDS',
'DocTypeDesc': 'Integrated Safeguards Data Sheet (ISDS), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000356161_20130305113209',
'EntityID': '000356161_20130305113209'},
{'DocDate': '16-JAN-2013',
'DocType': 'PID',
'DocTypeDesc': 'Project Information Document (PID), Vol.1 of 1',
'DocURL': 'http://www-wds.worldbank.org/servlet/WDSServlet?pcont=details&eid=000356161_20130305113716',
'EntityID': '000356161_20130305113716'}],
'projectfinancialtype': 'OTHER',
'projectstatusdisplay': 'Active',
'regionname': 'Middle East and North Africa',
'sector': [{'Name': 'Public administration- Other social services'},
{'Name': 'General public administration sector'}],
'sector1': {'Name': 'Public administration- Other social services',
'Percent': 70},
'sector2': {'Name': 'General public administration sector', 'Percent': 30},
'sector_namecode': [{'code': 'BS',
'name': 'Public administration- Other social services'},
{'code': 'BZ', 'name': 'General public administration sector'}],
'sectorcode': 'BZ,BS',
'source': 'IBRD',
'status': 'Active',
'supplementprojectflg': 'N',
'theme1': {'Name': 'Other economic management', 'Percent': 30},
'theme_namecode': [{'code': '24', 'name': 'Other economic management'},
{'code': '54', 'name': 'Social safety nets'}],
'themecode': '54,24',
'totalamt': 0,
'totalcommamt': 4700000,
'url': 'http://www.worldbank.org/projects/P144674?lang=en'}]
In [10]:
# load as Pandas dataframe
sample_json_df = pd.read_json('data/world_bank_projects_less.json')
sample_json_df
Out[10]:
_id
approvalfy
board_approval_month
boardapprovaldate
borrower
closingdate
country_namecode
countrycode
countryname
countryshortname
...
sectorcode
source
status
supplementprojectflg
theme1
theme_namecode
themecode
totalamt
totalcommamt
url
0
{u'$oid': u'52b213b38594d8a2be17c780'}
1999
November
2013-11-12T00:00:00Z
FEDERAL DEMOCRATIC REPUBLIC OF ETHIOPIA
2018-07-07T00:00:00Z
Federal Democratic Republic of Ethiopia!$!ET
ET
Federal Democratic Republic of Ethiopia
Ethiopia
...
ET,BS,ES,EP
IBRD
Active
N
{u'Percent': 100, u'Name': u'Education for all'}
[{u'code': u'65', u'name': u'Education for all'}]
65
130000000
130000000
http://www.worldbank.org/projects/P129828/ethi...
1
{u'$oid': u'52b213b38594d8a2be17c781'}
2015
November
2013-11-04T00:00:00Z
GOVERNMENT OF TUNISIA
NaN
Republic of Tunisia!$!TN
TN
Republic of Tunisia
Tunisia
...
BZ,BS
IBRD
Active
N
{u'Percent': 30, u'Name': u'Other economic man...
[{u'code': u'24', u'name': u'Other economic ma...
54,24
0
4700000
http://www.worldbank.org/projects/P144674?lang=en
2 rows × 50 columns
Using data in file 'data/world_bank_projects.json' and the techniques demonstrated above,
In [181]:
# load json data frame
dataFrame = pd.read_json('data/world_bank_projects.json')
In [183]:
dataFrame
Out[183]:
_id
approvalfy
board_approval_month
boardapprovaldate
borrower
closingdate
country_namecode
countrycode
countryname
countryshortname
...
sectorcode
source
status
supplementprojectflg
theme1
theme_namecode
themecode
totalamt
totalcommamt
url
0
{'$oid': '52b213b38594d8a2be17c780'}
1999
November
2013-11-12T00:00:00Z
FEDERAL DEMOCRATIC REPUBLIC OF ETHIOPIA
2018-07-07T00:00:00Z
Federal Democratic Republic of Ethiopia!$!ET
ET
Federal Democratic Republic of Ethiopia
Ethiopia
...
ET,BS,ES,EP
IBRD
Active
N
{'Name': 'Education for all', 'Percent': 100}
[{'name': 'Education for all', 'code': '65'}]
65
130000000
130000000
http://www.worldbank.org/projects/P129828/ethi...
1
{'$oid': '52b213b38594d8a2be17c781'}
2015
November
2013-11-04T00:00:00Z
GOVERNMENT OF TUNISIA
NaN
Republic of Tunisia!$!TN
TN
Republic of Tunisia
Tunisia
...
BZ,BS
IBRD
Active
N
{'Name': 'Other economic management', 'Percent...
[{'name': 'Other economic management', 'code':...
54,24
0
4700000
http://www.worldbank.org/projects/P144674?lang=en
2
{'$oid': '52b213b38594d8a2be17c782'}
2014
November
2013-11-01T00:00:00Z
MINISTRY OF FINANCE AND ECONOMIC DEVEL
NaN
Tuvalu!$!TV
TV
Tuvalu
Tuvalu
...
TI
IBRD
Active
Y
{'Name': 'Regional integration', 'Percent': 46}
[{'name': 'Regional integration', 'code': '47'...
52,81,25,47
6060000
6060000
http://www.worldbank.org/projects/P145310?lang=en
3
{'$oid': '52b213b38594d8a2be17c783'}
2014
October
2013-10-31T00:00:00Z
MIN. OF PLANNING AND INT'L COOPERATION
NaN
Republic of Yemen!$!RY
RY
Republic of Yemen
Yemen, Republic of
...
JB
IBRD
Active
N
{'Name': 'Participation and civic engagement',...
[{'name': 'Participation and civic engagement'...
59,57
0
1500000
http://www.worldbank.org/projects/P144665?lang=en
4
{'$oid': '52b213b38594d8a2be17c784'}
2014
October
2013-10-31T00:00:00Z
MINISTRY OF FINANCE
2019-04-30T00:00:00Z
Kingdom of Lesotho!$!LS
LS
Kingdom of Lesotho
Lesotho
...
FH,YW,YZ
IBRD
Active
N
{'Name': 'Export development and competitivene...
[{'name': 'Export development and competitiven...
41,45
13100000
13100000
http://www.worldbank.org/projects/P144933/seco...
5
{'$oid': '52b213b38594d8a2be17c785'}
2014
October
2013-10-31T00:00:00Z
REPUBLIC OF KENYA
NaN
Republic of Kenya!$!KE
KE
Republic of Kenya
Kenya
...
JB
IBRD
Active
Y
{'Name': 'Social safety nets', 'Percent': 100}
[{'name': 'Social safety nets', 'code': '54'}]
54
10000000
10000000
http://www.worldbank.org/projects/P146161?lang=en
6
{'$oid': '52b213b38594d8a2be17c786'}
2014
October
2013-10-29T00:00:00Z
GOVERNMENT OF INDIA
2019-06-30T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
TI
IBRD
Active
N
{'Name': 'Administrative and civil service ref...
[{'name': 'Administrative and civil service re...
39,25
500000000
500000000
http://www.worldbank.org/projects/P121185/firs...
7
{'$oid': '52b213b38594d8a2be17c787'}
2014
October
2013-10-29T00:00:00Z
PEOPLE'S REPUBLIC OF CHINA
NaN
People's Republic of China!$!CN
CN
People's Republic of China
China
...
LR
IBRD
Active
N
{'Name': 'Climate change', 'Percent': 100}
[{'name': 'Climate change', 'code': '81'}]
81
0
27280000
http://www.worldbank.org/projects/P127033/chin...
8
{'$oid': '52b213b38594d8a2be17c788'}
2014
October
2013-10-29T00:00:00Z
THE GOVERNMENT OF INDIA
2018-12-31T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
TI
IBRD
Active
N
{'Name': 'Other rural development', 'Percent':...
[{'name': 'Other rural development', 'code': '...
79
160000000
160000000
http://www.worldbank.org/projects/P130164/raja...
9
{'$oid': '52b213b38594d8a2be17c789'}
2014
October
2013-10-29T00:00:00Z
THE KINGDOM OF MOROCCO
2014-12-31T00:00:00Z
Kingdom of Morocco!$!MA
MA
Kingdom of Morocco
Morocco
...
BM,BC,BZ
IBRD
Active
N
{'Name': 'Other accountability/anti-corruption...
[{'name': 'Other accountability/anti-corruptio...
27,30,29
200000000
200000000
http://www.worldbank.org/projects/P130903?lang=en
10
{'$oid': '52b213b38594d8a2be17c78a'}
2014
October
2013-10-25T00:00:00Z
GOVERNMENT OF SOUTH SUDAN
NaN
Republic of South Sudan!$!SS
SS
Republic of South Sudan
South Sudan
...
AZ,JB,AH
IBRD
Active
Y
{'Name': 'Global food crisis response', 'Perce...
[{'name': 'Global food crisis response', 'code...
91
0
7530000
http://www.worldbank.org/projects/P145339?lang=en
11
{'$oid': '52b213b38594d8a2be17c78b'}
2014
October
2013-10-25T00:00:00Z
NaN
2017-12-31T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
JB,YC,WD,TI
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
81,87,52,78
250000000
250000000
http://www.worldbank.org/projects/P146653?lang=en
12
{'$oid': '52b213b38594d8a2be17c78c'}
2014
October
2013-10-24T00:00:00Z
GOVERNMENT OF GHANA
2019-06-30T00:00:00Z
Republic of Ghana!$!GH
GH
Republic of Ghana
Ghana
...
CZ
IBRD
Active
N
{'Name': '', 'Percent': 0}
NaN
NaN
97000000
97000000
http://www.worldbank.org/projects/P144140/gh-e...
13
{'$oid': '52b213b38594d8a2be17c78d'}
2014
October
2013-10-22T00:00:00Z
GOVERNMENT OF TIMOR LESTE
NaN
Democratic Republic of Timor-Leste!$!TP
TP
Democratic Republic of Timor-Leste
Timor-Leste
...
BV,TI
IBRD
Active
Y
{'Name': 'Regional integration', 'Percent': 20}
[{'name': 'Regional integration', 'code': '47'...
78,81,47
40000000
40000000
http://www.worldbank.org/projects/P130975/timo...
14
{'$oid': '52b213b38594d8a2be17c78e'}
2014
October
2013-10-22T00:00:00Z
GOVERNMENT OF JORDAN
NaN
Hashemite Kingdom of Jordan!$!JO
JO
Hashemite Kingdom of Jordan
Jordan
...
JB
IBRD
Active
N
{'Name': 'Social safety nets', 'Percent': 50}
[{'name': 'Social safety nets', 'code': '54'},...
53,56,54
0
9500000
http://www.worldbank.org/projects/P144832?lang=en
15
{'$oid': '52b213b38594d8a2be17c78f'}
2014
October
2013-10-17T00:00:00Z
MINISTRY OF FINANCE
2019-04-30T00:00:00Z
Samoa!$!WS
WS
Samoa
Samoa
...
TI
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
49,81,78
20000000
20000000
http://www.worldbank.org/projects/P145545?lang=en
16
{'$oid': '52b213b38594d8a2be17c790'}
2014
October
2013-10-17T00:00:00Z
MINISTRY OF FINANCE
2015-12-31T00:00:00Z
Samoa!$!WS
WS
Samoa
Samoa
...
AZ,AJ,AH
IBRD
Active
N
{'Name': 'Other rural development', 'Percent':...
[{'name': 'Other rural development', 'code': '...
79
5000000
5000000
http://www.worldbank.org/projects/P145938?lang=en
17
{'$oid': '52b213b38594d8a2be17c791'}
2014
October
2013-10-16T00:00:00Z
MINISTRY OF FINANCE AND BUDGET (MFB)
NaN
Republic of Madagascar!$!MG
MG
Republic of Madagascar
Madagascar
...
EP
IBRD
Active
N
{'Name': 'Education for all', 'Percent': 100}
[{'name': 'Education for all', 'code': '65'}]
65
0
85400000
http://www.worldbank.org/projects/P132616?lang=en
18
{'$oid': '52b213b38594d8a2be17c792'}
2014
October
2013-10-16T00:00:00Z
ROYAL GOVERNMENT OF CAMBODIA
NaN
Kingdom of Cambodia!$!KH
KH
Kingdom of Cambodia
Cambodia
...
BK,JB,BH,BC,JA
IBRD
Active
Y
{'Name': 'Child health', 'Percent': 17}
[{'name': 'Child health', 'code': '63'}, {'nam...
69,57,25,67,63
0
13450000
http://www.worldbank.org/projects/P146271?lang=en
19
{'$oid': '52b213b38594d8a2be17c793'}
2014
October
2013-10-10T00:00:00Z
MINISTRY OF FINANCE
NaN
Kingdom of Morocco!$!MA
MA
Kingdom of Morocco
Morocco
...
BH,BC,BZ
IBRD
Active
N
{'Name': 'Public expenditure, financial manage...
[{'name': 'Public expenditure, financial manag...
25,26,27
0
4350000
http://www.worldbank.org/projects/P143979?lang=en
20
{'$oid': '52b213b38594d8a2be17c794'}
2014
October
2013-10-09T00:00:00Z
AGA KHAN DEVELOPMENT NETWORK (AKDN)
NaN
Kyrgyz Republic!$!KG
KG
Kyrgyz Republic
Kyrgyz Republic
...
JB
IBRD
Active
N
{'Name': 'Conflict prevention and post-conflic...
[{'name': 'Conflict prevention and post-confli...
57,58
0
2000000
http://www.worldbank.org/projects/P132577?lang=en
21
{'$oid': '52b213b38594d8a2be17c795'}
2014
October
2013-10-07T00:00:00Z
NEPAL
NaN
Nepal!$!NP
NP
Nepal
Nepal
...
BH,YW,JB
IBRD
Active
N
{'Name': 'Urban services and housing for the p...
[{'name': 'Urban services and housing for the ...
57,71
0
2750000
http://www.worldbank.org/projects/P145359?lang=en
22
{'$oid': '52b213b38594d8a2be17c796'}
2014
October
2013-10-07T00:00:00Z
MINISTRY OF PLANNING AND INTERNATIONAL C
NaN
Hashemite Kingdom of Jordan!$!JO
JO
Hashemite Kingdom of Jordan
Jordan
...
WC,BS,BH,TZ,WB
IBRD
Active
N
{'Name': 'Other social development', 'Percent'...
[{'name': 'Other social development', 'code': ...
58,62
0
50000000
http://www.worldbank.org/projects/P147689?lang=en
23
{'$oid': '52b213b38594d8a2be17c797'}
2014
October
2013-10-03T00:00:00Z
REPUBLIC OF TAJIKISTAN
NaN
Republic of Tajikistan!$!TJ
TJ
Republic of Tajikistan
Tajikistan
...
JA
IBRD
Active
N
{'Name': 'Nutrition and food security', 'Perce...
[{'name': 'Nutrition and food security', 'code...
63,68
0
2800000
http://www.worldbank.org/projects/P146109?lang=en
24
{'$oid': '52b213b38594d8a2be17c798'}
2014
September
2013-09-30T00:00:00Z
REPUBLIC OF AZERBAIJAN
2018-12-31T00:00:00Z
Republic of Azerbaijan!$!AZ
AZ
Republic of Azerbaijan
Azerbaijan
...
AB,AZ,YA
IBRD
Active
N
{'Name': 'Rural markets', 'Percent': 30}
[{'name': 'Rural markets', 'code': '75'}, {'na...
56,78,76,75
34500000
34500000
http://www.worldbank.org/projects/P122812/thir...
25
{'$oid': '52b213b38594d8a2be17c799'}
2014
September
2013-09-30T00:00:00Z
UNIVERSITY OF QUEENSLAND
NaN
East Asia and Pacific!$!4E
4E
East Asia and Pacific
East Asia and Pacific
...
AB,AZ
IBRD
Active
N
{'Name': 'Other environment and natural resour...
[{'name': 'Other environment and natural resou...
80,81,86
0
4500000
http://www.worldbank.org/projects/P123933/capt...
26
{'$oid': '52b213b38594d8a2be17c79a'}
2014
September
2013-09-30T00:00:00Z
LAO PEOPLES DEMOCRATIC REPUBLIC
2014-03-31T00:00:00Z
Lao People's Democratic Republic!$!LA
LA
Lao People's Democratic Republic
Lao People's Democratic Republic
...
LG,FB,EZ,YZ,BC
IBRD
Closed
N
{'Name': 'Regulation and competition policy', ...
[{'name': 'Regulation and competition policy',...
67,27,49,40
20000000
20000000
http://www.worldbank.org/projects/P143025/lao-...
27
{'$oid': '52b213b38594d8a2be17c79b'}
2014
September
2013-09-30T00:00:00Z
PACIFIC AVIATION SECURITY OFFICE
2018-12-31T00:00:00Z
Pacific Islands!$!4P
4P
Pacific Islands
Pacific Islands
...
BV,TV
IBRD
Active
N
{'Name': 'Climate change', 'Percent': 5}
[{'name': 'Climate change', 'code': '81'}, {'n...
52,47,25,81
2150000
2150000
http://www.worldbank.org/projects/P145057/paci...
28
{'$oid': '52b213b38594d8a2be17c79c'}
2014
September
2013-09-30T00:00:00Z
SOLOMON ISLANDS GOVERNMENT
NaN
Solomon Islands!$!SB
SB
Solomon Islands
Solomon Islands
...
BZ,AZ
IBRD
Active
Y
{'Name': 'Rural policies and institutions', 'P...
[{'name': 'Rural policies and institutions', '...
57,78,77
3000000
3000000
http://www.worldbank.org/projects/P146021?lang=en
29
{'$oid': '52b213b38594d8a2be17c79d'}
2014
September
2013-09-27T00:00:00Z
GOVERNMENT OF MOZAMBIQUE
NaN
Republic of Mozambique!$!MZ
MZ
Republic of Mozambique
Mozambique
...
JB,BW,WZ,WD
IBRD
Active
Y
{'Name': 'Other social development', 'Percent'...
[{'name': 'Other social development', 'code': ...
85,62
32000000
32000000
http://www.worldbank.org/projects/P146098?lang=en
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
470
{'$oid': '52b213b38594d8a2be17c956'}
2013
September
2012-09-20T00:00:00Z
GOVERNMENT OF LIBERIA
NaN
Republic of Liberia!$!LR
LR
Republic of Liberia
Liberia
...
BV,TI
IBRD
Active
Y
{'Name': 'Trade facilitation and market access...
[{'name': 'Trade facilitation and market acces...
78,49
50000000
50000000
http://www.worldbank.org/projects/P129654/libe...
471
{'$oid': '52b213b38594d8a2be17c957'}
2013
September
2012-09-20T00:00:00Z
GOVERNMENT OF BANGLADESH
2018-12-31T00:00:00Z
People's Republic of Bangladesh!$!BD
BD
People's Republic of Bangladesh
Bangladesh
...
BU,LA,LR
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
59,81,57,78
155000000
155000000
http://www.worldbank.org/projects/P131263/rura...
472
{'$oid': '52b213b38594d8a2be17c958'}
2013
September
2012-09-13T00:00:00Z
MINISTRY OF NATURE PROTECTION
2014-09-30T00:00:00Z
Republic of Armenia!$!AM
AM
Republic of Armenia
Armenia
...
BC
IBRD
Active
N
{'Name': 'Other environment and natural resour...
[{'name': 'Other environment and natural resou...
86
0
150000
http://www.worldbank.org/projects/P131631/repo...
473
{'$oid': '52b213b38594d8a2be17c959'}
2013
September
2012-09-13T00:00:00Z
MINISTRY OF ENVIRONMENT, FORESTS, WATER
NaN
Republic of Albania!$!AL
AL
Republic of Albania
Albania
...
BC
IBRD
Active
N
{'Name': 'Other environment and natural resour...
[{'name': 'Other environment and natural resou...
86
0
150000
http://www.worldbank.org/projects/P132679/land...
474
{'$oid': '52b213b38594d8a2be17c95a'}
2013
September
2012-09-11T00:00:00Z
GOVERNMENT OF PAKISTAN
2017-06-30T00:00:00Z
Islamic Republic of Pakistan!$!PK
PK
Islamic Republic of Pakistan
Pakistan
...
BM,BH
IBRD
Active
N
{'Name': 'Municipal finance', 'Percent': 34}
[{'name': 'Municipal finance', 'code': '72'}, ...
73,72
150000000
150000000
http://www.worldbank.org/projects/P112901/pk-p...
475
{'$oid': '52b213b38594d8a2be17c95b'}
2013
September
2012-09-11T00:00:00Z
GOVERNMENT OF INDONESIA
2018-03-31T00:00:00Z
Republic of Indonesia!$!ID
ID
Republic of Indonesia
Indonesia
...
BO,BH,LZ,TZ,WZ
IBRD
Active
N
{'Name': 'Infrastructure services for private ...
[{'name': 'Infrastructure services for private...
72,39
29600000
29600000
http://www.worldbank.org/projects/P118916/infr...
476
{'$oid': '52b213b38594d8a2be17c95c'}
2013
September
2012-09-11T00:00:00Z
SOCIALIST REPUBLIC OF VIETNAM
2018-12-31T00:00:00Z
Socialist Republic of Vietnam!$!VN
VN
Socialist Republic of Vietnam
Vietnam
...
BU,LT,LA
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
78
448900000
448900000
http://www.worldbank.org/projects/P125996/dist...
477
{'$oid': '52b213b38594d8a2be17c95d'}
2013
September
2012-09-11T00:00:00Z
REPUBLIC OF UZBEKISTAN
NaN
Republic of Uzbekistan!$!UZ
UZ
Republic of Uzbekistan
Uzbekistan
...
FH
IBRD
Active
Y
{'Name': 'Micro, Small and Medium Enterprise s...
[{'name': 'Micro, Small and Medium Enterprise ...
75,41
40000000
40000000
http://www.worldbank.org/projects/P126962/addi...
478
{'$oid': '52b213b38594d8a2be17c95e'}
2013
September
2012-09-11T00:00:00Z
ISLAMIC REPUBLIC OF PAKISTAN
NaN
Islamic Republic of Pakistan!$!PK
PK
Islamic Republic of Pakistan
Pakistan
...
BH
IBRD
Active
Y
{'Name': 'Administrative and civil service ref...
[{'name': 'Administrative and civil service re...
83,36,25
70000000
70000000
http://www.worldbank.org/projects/P131266/punj...
479
{'$oid': '52b213b38594d8a2be17c95f'}
2013
September
2012-09-10T00:00:00Z
UT'Z CHE
2016-05-07T00:00:00Z
Republic of Guatemala!$!GT
GT
Republic of Guatemala
Guatemala
...
AZ
IBRD
Active
N
{'Name': 'Other social development', 'Percent'...
[{'name': 'Other social development', 'code': ...
62
0
2510000
http://www.worldbank.org/projects/P130412/stre...
480
{'$oid': '52b213b38594d8a2be17c960'}
2013
September
2012-09-10T00:00:00Z
GOVERNMENT OF ZAMBIA
2014-12-31T00:00:00Z
Republic of Zambia!$!ZM
ZM
Republic of Zambia
Zambia
...
LS
IBRD
Active
N
{'Name': 'Other public sector governance', 'Pe...
[{'name': 'Other public sector governance', 'c...
30
0
350000
http://www.worldbank.org/projects/P131881/zamb...
481
{'$oid': '52b213b38594d8a2be17c961'}
2013
September
2012-09-06T00:00:00Z
GOVERNMENT OF INDIA
2015-12-31T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
BC,EC,BQ,BH
IBRD
Active
N
{'Name': 'Child health', 'Percent': 23}
[{'name': 'Child health', 'code': '63'}, {'nam...
68,59,57,63
106000000
106000000
http://www.worldbank.org/projects/P121731/icds...
482
{'$oid': '52b213b38594d8a2be17c962'}
2013
September
2012-09-06T00:00:00Z
GOVERNMENT OF INDIA
2018-12-31T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
AI,YA,AH,BL,AB
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
79,85,86,78
60000000
60000000
http://www.worldbank.org/projects/P122486/karn...
483
{'$oid': '52b213b38594d8a2be17c963'}
2013
September
2012-09-06T00:00:00Z
GOVERNMENT OF INDIA
2013-09-30T00:00:00Z
Republic of India!$!IN
IN
Republic of India
India
...
CZ,AH,LA,AI,LH
IBRD
Closed
N
{'Name': 'Pollution management and environment...
[{'name': 'Pollution management and environmen...
82,78,81,84
100000000
100000000
http://www.worldbank.org/projects/P124041/hima...
484
{'$oid': '52b213b38594d8a2be17c964'}
2013
September
2012-09-06T00:00:00Z
ILO, MINLAND & CFSI & BANK
2015-12-31T00:00:00Z
Republic of the Philippines!$!PH
PH
Republic of the Philippines
Philippines
...
EV,FH,BZ,JB
IBRD
Active
Y
{'Name': 'Rural non-farm income generation', '...
[{'name': 'Rural non-farm income generation', ...
78,58,41,76
0
5570000
http://www.worldbank.org/projects/P132238/mult...
485
{'$oid': '52b213b38594d8a2be17c965'}
2013
September
2012-09-05T00:00:00Z
GOVERNMENT OF MONGOLIA
2013-12-31T00:00:00Z
Mongolia!$!MN
MN
Mongolia
Mongolia
...
BZ,JA,AJ
IBRD
Active
N
{'Name': 'Other communicable diseases', 'Perce...
[{'name': 'Other communicable diseases', 'code...
64
0
2900000
http://www.worldbank.org/projects/P131204/capa...
486
{'$oid': '52b213b38594d8a2be17c966'}
2013
September
2012-09-01T00:00:00Z
GOVERNMENT OF LEBANON & JORDAN
2015-01-31T00:00:00Z
Middle East and North Africa!$!5M
5M
Middle East and North Africa
Middle East and North Africa
...
BZ,BS,BQ,BN
IBRD
Active
N
{'Name': 'Other public sector governance', 'Pe...
[{'name': 'Other public sector governance', 'c...
54,55,56,30
0
2400000
http://www.worldbank.org/projects/P132097/5m-d...
487
{'$oid': '52b213b38594d8a2be17c967'}
2013
August
2012-08-30T00:00:00Z
UNITED MEXICAN STATES
2017-08-31T00:00:00Z
United Mexican States!$!MX
MX
United Mexican States
Mexico
...
YA,BL,AB
IBRD
Active
N
{'Name': 'Biodiversity', 'Percent': 20}
[{'name': 'Biodiversity', 'code': '80'}, {'nam...
82,79,77,80
0
11690000
http://www.worldbank.org/projects/P121116/sust...
488
{'$oid': '52b213b38594d8a2be17c968'}
2013
August
2012-08-30T00:00:00Z
THE STATE OF RIO DE JANEIRO
2014-01-31T00:00:00Z
Federative Republic of Brazil!$!BR
BR
Federative Republic of Brazil
Brazil
...
JA,EZ,BH
IBRD
Closed
N
{'Name': 'Health system performance', 'Percent...
[{'name': 'Health system performance', 'code':...
65,28,27,67
300000000
300000000
http://www.worldbank.org/projects/P126465/rio-...
489
{'$oid': '52b213b38594d8a2be17c969'}
2013
August
2012-08-30T00:00:00Z
UN-HABITAT
2015-06-30T00:00:00Z
The Independent State of Papua New Guine!$!PG
PG
The Independent State of Papua New Guine
Papua New Guinea
...
BW
IBRD
Closed
N
{'Name': 'Urban services and housing for the p...
[{'name': 'Urban services and housing for the ...
73,55,52,71
0
350000
http://www.worldbank.org/projects/P128763/papu...
490
{'$oid': '52b213b38594d8a2be17c96a'}
2013
August
2012-08-29T00:00:00Z
GOVERNMENT OF NEPAL
2014-06-30T00:00:00Z
Nepal!$!NP
NP
Nepal
Nepal
...
BZ
IBRD
Active
N
{'Name': 'Public expenditure, financial manage...
[{'name': 'Public expenditure, financial manag...
29,27
0
800000
http://www.worldbank.org/projects/P131860/stre...
491
{'$oid': '52b213b38594d8a2be17c96b'}
2013
August
2012-08-24T00:00:00Z
PALESTINIAN WATER AUTHORITY
2014-03-31T00:00:00Z
West Bank and Gaza!$!GZ
GZ
West Bank and Gaza
West Bank and Gaza
...
WC,WA
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
78
0
3650000
http://www.worldbank.org/projects/P123322/wate...
492
{'$oid': '52b213b38594d8a2be17c96c'}
2013
August
2012-08-21T00:00:00Z
GOVERNMENT OF PAKISTAN
2015-06-30T00:00:00Z
Islamic Republic of Pakistan!$!PK
PK
Islamic Republic of Pakistan
Pakistan
...
EP
IBRD
Active
N
{'Name': 'Education for all', 'Percent': 70}
[{'name': 'Education for all', 'code': '65'}, ...
59,65
0
10000000
http://www.worldbank.org/projects/P128096/paki...
493
{'$oid': '52b213b38594d8a2be17c96d'}
2013
August
2012-08-21T00:00:00Z
GOVERNMENT OF BANGLADESH
2015-04-30T00:00:00Z
People's Republic of Bangladesh!$!BD
BD
People's Republic of Bangladesh
Bangladesh
...
BC
IBRD
Active
N
{'Name': 'Other environment and natural resour...
[{'name': 'Other environment and natural resou...
86
0
150000
http://www.worldbank.org/projects/P132138/revi...
494
{'$oid': '52b213b38594d8a2be17c96e'}
2013
August
2012-08-17T00:00:00Z
MINISTRY OF EDUCATION
2014-06-30T00:00:00Z
Nepal!$!NP
NP
Nepal
Nepal
...
EZ
IBRD
Active
N
{'Name': 'Natural disaster management', 'Perce...
[{'name': 'Natural disaster management', 'code...
52
0
1510000
http://www.worldbank.org/projects/P129177/nepa...
495
{'$oid': '52b213b38594d8a2be17c96f'}
2013
August
2012-08-10T00:00:00Z
THE COMPETITIVENESS COMPANY
2013-08-31T00:00:00Z
Jamaica!$!JM
JM
Jamaica
Jamaica
...
EV,AZ
IBRD
Closed
N
{'Name': 'Regulation and competition policy', ...
[{'name': 'Regulation and competition policy',...
62,40
0
50000
http://www.worldbank.org/projects/P127299/tech...
496
{'$oid': '52b213b38594d8a2be17c970'}
2013
August
2012-08-09T00:00:00Z
LAO PEOPLES DEMOCRATIC REPUBLIC
2012-12-31T00:00:00Z
Lao People's Democratic Republic!$!LA
LA
Lao People's Democratic Republic
Lao People's Democratic Republic
...
YZ,JA,EZ,FZ,BC
IBRD
Closed
N
{'Name': 'Child health', 'Percent': 14}
[{'name': 'Child health', 'code': '63'}, {'nam...
65,27,49,63
20000000
20000000
http://www.worldbank.org/projects/P125298/lao-...
497
{'$oid': '52b213b38594d8a2be17c971'}
2013
August
2012-08-03T00:00:00Z
GOVERNMENT OF THE REPUBLIC OF GUINEA
2014-12-31T00:00:00Z
Republic of Guinea!$!GN
GN
Republic of Guinea
Guinea
...
AB,AH,AI
IBRD
Active
N
{'Name': 'Global food crisis response', 'Perce...
[{'name': 'Global food crisis response', 'code...
91
0
20000000
http://www.worldbank.org/projects/P128309/seco...
498
{'$oid': '52b213b38594d8a2be17c972'}
2013
August
2012-08-02T00:00:00Z
REPUBLIC OF INDONESIA
2017-09-30T00:00:00Z
Republic of Indonesia!$!ID
ID
Republic of Indonesia
Indonesia
...
YA,BL,AB
IBRD
Active
N
{'Name': 'Rural services and infrastructure', ...
[{'name': 'Rural services and infrastructure',...
77,91,78
80000000
80000000
http://www.worldbank.org/projects/P117243/sust...
499
{'$oid': '52b213b38594d8a2be17c973'}
2013
August
2012-08-02T00:00:00Z
GOVERMENT OF KENYA
2018-12-31T00:00:00Z
Republic of Kenya!$!KE
KE
Republic of Kenya
Kenya
...
BV,TC
IBRD
Active
N
{'Name': 'Municipal governance and institution...
[{'name': 'Municipal governance and institutio...
39,49,88,73
300000000
300000000
http://www.worldbank.org/projects/P126321/keny...
500 rows × 50 columns
In [191]:
dataFrame.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 500 entries, 0 to 499
Data columns (total 50 columns):
_id 500 non-null object
approvalfy 500 non-null int64
board_approval_month 500 non-null object
boardapprovaldate 500 non-null object
borrower 485 non-null object
closingdate 370 non-null object
country_namecode 500 non-null object
countrycode 500 non-null object
countryname 500 non-null object
countryshortname 500 non-null object
docty 446 non-null object
envassesmentcategorycode 430 non-null object
grantamt 500 non-null int64
ibrdcommamt 500 non-null int64
id 500 non-null object
idacommamt 500 non-null int64
impagency 472 non-null object
lendinginstr 495 non-null object
lendinginstrtype 495 non-null object
lendprojectcost 500 non-null int64
majorsector_percent 500 non-null object
mjsector_namecode 500 non-null object
mjtheme 491 non-null object
mjtheme_namecode 500 non-null object
mjthemecode 500 non-null object
prodline 500 non-null object
prodlinetext 500 non-null object
productlinetype 500 non-null object
project_abstract 362 non-null object
project_name 500 non-null object
projectdocs 446 non-null object
projectfinancialtype 500 non-null object
projectstatusdisplay 500 non-null object
regionname 500 non-null object
sector 500 non-null object
sector1 500 non-null object
sector2 380 non-null object
sector3 265 non-null object
sector4 174 non-null object
sector_namecode 500 non-null object
sectorcode 500 non-null object
source 500 non-null object
status 500 non-null object
supplementprojectflg 498 non-null object
theme1 500 non-null object
theme_namecode 491 non-null object
themecode 491 non-null object
totalamt 500 non-null int64
totalcommamt 500 non-null int64
url 500 non-null object
dtypes: int64(7), object(43)
memory usage: 199.2+ KB
In [192]:
dataFrame.columns
Out[192]:
Index(['_id', 'approvalfy', 'board_approval_month', 'boardapprovaldate',
'borrower', 'closingdate', 'country_namecode', 'countrycode',
'countryname', 'countryshortname', 'docty', 'envassesmentcategorycode',
'grantamt', 'ibrdcommamt', 'id', 'idacommamt', 'impagency',
'lendinginstr', 'lendinginstrtype', 'lendprojectcost',
'majorsector_percent', 'mjsector_namecode', 'mjtheme',
'mjtheme_namecode', 'mjthemecode', 'prodline', 'prodlinetext',
'productlinetype', 'project_abstract', 'project_name', 'projectdocs',
'projectfinancialtype', 'projectstatusdisplay', 'regionname', 'sector',
'sector1', 'sector2', 'sector3', 'sector4', 'sector_namecode',
'sectorcode', 'source', 'status', 'supplementprojectflg', 'theme1',
'theme_namecode', 'themecode', 'totalamt', 'totalcommamt', 'url'],
dtype='object')
In [193]:
dataFrame.groupby(dataFrame.countryshortname).count().sort('_id', ascending=False).head(10)
Out[193]:
_id
approvalfy
board_approval_month
boardapprovaldate
borrower
closingdate
country_namecode
countrycode
countryname
docty
...
sectorcode
source
status
supplementprojectflg
theme1
theme_namecode
themecode
totalamt
totalcommamt
url
countryshortname
China
19
19
19
19
19
16
19
19
19
19
...
19
19
19
19
19
17
17
19
19
19
Indonesia
19
19
19
19
19
15
19
19
19
14
...
19
19
19
19
19
19
19
19
19
19
Vietnam
17
17
17
17
17
14
17
17
17
16
...
17
17
17
16
17
17
17
17
17
17
India
16
16
16
16
15
13
16
16
16
16
...
16
16
16
16
16
16
16
16
16
16
Yemen, Republic of
13
13
13
13
13
8
13
13
13
11
...
13
13
13
13
13
13
13
13
13
13
Nepal
12
12
12
12
11
7
12
12
12
12
...
12
12
12
12
12
11
11
12
12
12
Bangladesh
12
12
12
12
12
10
12
12
12
12
...
12
12
12
12
12
12
12
12
12
12
Morocco
12
12
12
12
12
11
12
12
12
10
...
12
12
12
12
12
11
11
12
12
12
Mozambique
11
11
11
11
11
9
11
11
11
10
...
11
11
11
11
11
11
11
11
11
11
Africa
11
11
11
11
11
7
11
11
11
10
...
11
11
11
11
11
11
11
11
11
11
10 rows × 49 columns
In [180]:
themeNameCode = []
for codes in dataFrame.mjtheme_namecode:
themeNameCode += codes
themeNameCode = json_normalize(themeNameCode)
themeNameCode['count']=themeNameCode.groupby('code').transform('count')
themeNameCode.sort('count').drop_duplicates().head(10)
Out[180]:
code
name
count
1411
3
Rule of law
15
1212
1
Economic management
38
598
9
Urban development
50
968
5
Trade and integration
77
1133
7
Social dev/gender/inclusion
130
1188
4
Financial and private sector development
146
1080
6
Social protection and risk management
168
1008
2
Public sector governance
199
1151
8
Human development
210
435
10
Rural development
216
In [1]:
dataFrame = pd.read_json('data/world_bank_projects.json')
#Create dictionary Code:Name to replace empty names.
codeNameDict = {}
for codes in dataFrame.mjtheme_namecode:
for code in codes:
if code['name']!='':
codeNameDict[code['code']]=code['name']
index=0
for codes in dataFrame.mjtheme_namecode:
innerIndex=0
for code in codes:
if code['name']=='':
print ("Code name empty ", code['code'])
dataFrame.mjtheme_namecode[index][innerIndex]['name']=codeNameDict[code['code']]
innerIndex += 1
index += 1
dataFrame.mjtheme_namecode
themeNameCode = []
for codes in dataFrame.mjtheme_namecode:
print (code)
themeNameCode += code
themeNameCode
# themeNameCode = json_normalize(themeNameCode)
# themeNameCode['count']=themeNameCode.groupby('code').transform('count')
# themeNameCode.sort('count').drop_duplicates().head(10)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-1-aea3485c0fd1> in <module>()
----> 1 dataFrame = pd.read_json('data/world_bank_projects.json')
2 #Create dictionary Code:Name to replace empty names.
3 codeNameDict = {}
4 for codes in dataFrame.mjtheme_namecode:
5 for code in codes:
NameError: name 'pd' is not defined
In [168]:
In [ ]:
In [ ]:
Content source: abhipr1/DATA_SCIENCE_INTENSIVE
Similar notebooks: